def plus(args):
    sum = 0
    for i in args:
        sum = sum + i
    return sum


def minus(x, y):
    return x - y


def multiply(args):
    sum = 1
    for i in args:
        sum = sum * i
    return sum


def divide(x, y):
    z = x / y
    return z


def main():
    while True:
        yunsuan = input("1、加法\n2、减法\n3、乘法\n4、除法\n5、退出\n请输入要进行的运算：")
        if yunsuan == "5":
            exit()
        if yunsuan == "1":
            aa = int(input("请输入你要加几个数："))
            args = []
            bb = 1
            while bb <= aa:
                num = int(input("请输入你要加的第{}个数：".format(bb)))
                args.append(num)
                bb = bb + 1
            cc = plus(args)
            print("和是{}".format(cc))
        elif yunsuan == "2":
            x = int(input("请输入被减数："))
            y = int(input("请输入减数："))
            print("差是{}".format(minus(x, y)))
        elif yunsuan == "3":
            aa = int(input("请输入你要乘几个数："))
            args = []
            bb = 1
            while bb <= aa:
                num = int(input("请输入你要乘的第{}个数：".format(bb)))
                args.append(num)
                bb = bb + 1
            cc = multiply(args)
            print("积是{}".format(cc))
        elif yunsuan == "4":
            x = int(input("请输入被除数："))
            y = int(input("请输入除数（不为0）："))
            if y == 0:
                print("除数不能为0！")
            else:
                print("商是{}".format(divide(x, y)))


main()